/**   
 * @Title: ShiyixuanwuBuyingInfo.java 
 * @Package com.esun.share.po 
 * @Description: TODO(十一选五购买的信息) 
 * @author Miko baoz@500wan.com   
 * @date 2011-1-18 下午02:29:18  
 */
package com.esun.rabbit2.viewer.mainact.lotteryhallact.shiyixuanwu.rabbittrunk;

import android.widget.TextView;

import com.esun.util.log.EDebug;

/**
 * @ClassName: ShiyixuanwuBuyingInfo
 * @Description: TODO(十一选五购买信息)
 * @author Miko baoz@500wan.com
 * @date 2011-1-18 下午02:29:18
 * 
 */
public class ShiyixuanwuBuyingInfo {

	private static ShiyixuanwuBuyingInfo shiyixuanwuBuy = null;

	public static ShiyixuanwuBuyingInfo getBuyingInfo() {

		if (shiyixuanwuBuy == null) {

			return shiyixuanwuBuy = new ShiyixuanwuBuyingInfo();

		} else {

			return shiyixuanwuBuy;
		}
	}

	// 第一键盘选号
	private StringBuilder space1 = new StringBuilder();

	// 第二键盘选号
	private StringBuilder space2 = new StringBuilder();

	// 第三键盘选号
	private StringBuilder space3 = new StringBuilder();

	// 注数
	private int voteLine = 0;

	// 金额
	private int money = 0;

	// 注数显示
	private TextView tvVoteLine = null;

	// 金额显示
	private TextView tvMoney = null;

	// 当前期是否可以购买
	private boolean canBuy = false;

	// 购买的期号
	private String termNum;

	// 玩法ID
	private String playingID;

	// 购买失败信息
	private String buyErrorMsg = "发起购买失败";

	private String maxMultiple;

	private String maxTermsCanbuy;

	public StringBuilder getSpace1() {
		return space1;
	}

	public void setSpace1(String[] strSpace1) {

		if (strSpace1.length == 0) {
			space1 = new StringBuilder();
		} else {
			space1.delete(0, space1.length());
			for (int i = 0; i < strSpace1.length; i++) {
				if (strSpace1[i] != null) {
					this.space1.append(strSpace1[i]).append(",");
				}
			}
			if (space1.length() > 0) {
				this.space1.setLength(this.space1.length() - 1);
			}
		}

		EDebug.o(this, "Space1 is : " + space1.toString());

	}

	public StringBuilder getSpace2() {
		return space2;
	}

	public void setSpace2(String[] strSpace2) {

		if (strSpace2.length == 0) {
			space2 = new StringBuilder();
		} else {
			space2.delete(0, space2.length());

			for (int i = 0; i < strSpace2.length; i++) {
				if (strSpace2[i] != null) {
					this.space2.append(strSpace2[i]).append(",");
				}
			}
			if (space2.length() > 0) {
				this.space2.setLength(this.space2.length() - 1);
			}
		}
		EDebug.o(this, "Space2 is : " + space2.toString());

	}

	public StringBuilder getSpace3() {
		return space3;
	}

	public void setSpace3(String[] strSpace3) {

		if (strSpace3.length == 0) {
			space3 = new StringBuilder();
		} else {
			space3.delete(0, space3.length());

			for (int i = 0; i < strSpace3.length; i++) {
				if (strSpace3[i] != null) {
					this.space3.append(strSpace3[i]).append(",");
				}
			}
			if (space3.length() > 0) {
				this.space3.setLength(this.space3.length() - 1);
			}
		}

		EDebug.o(this, "Space3 is : " + space3.toString());
	}

	public int getVoteLine() {
		return voteLine;
	}

	public void setVoteLine(int voteLine) {

		money = voteLine * 2;

		this.voteLine = voteLine;
	}

	public int getMoney() {

		return money;
	}

	public void showVoteLine() {
		tvVoteLine.setText(String.valueOf(voteLine));
	}

	public void showMoney() {
		tvMoney.setText(String.valueOf(money));
	}

	public void setTvVoteLine(TextView tvVoteLine) {
		this.tvVoteLine = tvVoteLine;
	}

	public void setTvMoney(TextView tvMoney) {
		this.tvMoney = tvMoney;
	}

	public boolean isCanBuy() {
		return canBuy;
	}

	public void setCanBuy(boolean canBuy) {
		this.canBuy = canBuy;
	}

	public String getTermNum() {
		return termNum;
	}

	public void setTermNum(String termNum) {
		this.termNum = termNum;
	}

	public String getPlayingID() {

		ShiyixuanwuUtils.getPlayingID();

		return playingID;
	}

	public void setPlayingID(String playingID) {
		this.playingID = playingID;
	}

	public String getBuyErrorMsg() {
		return buyErrorMsg;
	}

	public void setBuyErrorMsg(String buyErrorMsg) {
		this.buyErrorMsg = buyErrorMsg;
	}

	public String getMaxMultiple() {
		return maxMultiple;
	}

	public void setMaxMultiple(String maxMultiple) {
		this.maxMultiple = maxMultiple;
	}

	public String getMaxTermsCanbuy() {
		return maxTermsCanbuy;
	}

	public void setMaxTermsCanbuy(String maxTermsCanbuy) {
		this.maxTermsCanbuy = maxTermsCanbuy;
	}

	/**
	 * @Title: replaceAllData
	 * @Description: TODO(清空所有选号数据)
	 * @return void 返回类型
	 */
	public void replaceAllData() {
		space1.delete(0, space1.length());
		space2.delete(0, space2.length());
		space3.delete(0, space3.length());

		voteLine = 0;
		money = 0;

		tvMoney.setText("0");
		tvVoteLine.setText("0");
	}

	public String getBuyNum() {

		StringBuilder sbTemp = new StringBuilder();

		int playDetail = ShiyixuanwuPlayStyle.getPlayStyle().getDetail();
		int playStyle = ShiyixuanwuPlayStyle.getPlayStyle().getStyle();

		if (playDetail == 1) {
			sbTemp.append(ShiyixuanwuUtils.getFreeLottery());
		} else if (playDetail == 3) {
			sbTemp.append(ShiyixuanwuUtils.getFreeLottery());
		} else {
			sbTemp.append(ShiyixuanwuUtils.getHeadLottery(playStyle));
		}

		return sbTemp.toString();
	}

	/**
	 * @Title: getBuying
	 * @Description: TODO(获得购买的号码)
	 * @param @param playID
	 * @return String 购买号码
	 */
	public String getBuying(String multipleNum, String stageNum, String alertMoney, boolean bingoStop) {

		StringBuilder sbTemp = new StringBuilder();

		int playDetail = ShiyixuanwuPlayStyle.getPlayStyle().getDetail();
		int playStyle = ShiyixuanwuPlayStyle.getPlayStyle().getStyle();

		sbTemp.append(DataShare.SHIYIXUANWU).append(DataShare.ONESPACE);

		sbTemp.append("[").append(getPlayingID()).append("]");

		if (playDetail == 1) {
			sbTemp.append(ShiyixuanwuUtils.getFreeLottery());
		} else if (playDetail == 3) {
			sbTemp.append(ShiyixuanwuUtils.getFreeLottery());
		} else {
			sbTemp.append(ShiyixuanwuUtils.getHeadLottery(playStyle));
		}

		sbTemp.append(DataShare.ONESPACE);

		// 追号期数内中奖后停止追号
		if (bingoStop) {
			sbTemp.append(DataShare.NUM1);
		} else {
			sbTemp.append(DataShare.NUM0);
		}

		sbTemp.append(DataShare.ONESPACE);
		// 倍数
		sbTemp.append(stageNum).append(DataShare.ONESPACE);

		// 期号列表
		// sbTemp.append(termNum).append(DataShare.ONESPACE);

		// 总期数
		sbTemp.append(multipleNum).append(DataShare.ONESPACE);

		sbTemp.append(alertMoney).append(DataShare.ONESPACE);

		sbTemp.append("Android");
		// System.out.println("++++++++++++++++>>>>>>>>>>>>>>"+sbTemp.toString());
		return sbTemp.toString();
	}
}
